<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>注册局部组件</title>
</head>

<body>
    <div id="app">
        <global-component></global-component>
        <hello-world></hello-world>
    </div>

    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">
        // 全局组件中使用未注册的局部组件
        // 页面有报错，局部组件未注册
        Vue.component('global-component', {
            template: '<div>全局---<hello-world></hello-world></div>'
        });

        // 局部组件
        var HelloWorld = {
            data: function () {
                return {
                    msg: '局部'
                }
            },
            template: '<div>{{msg}}</div>'
        };

        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue !'
            },
            // 注册组件
            components: {
                'hello-world': HelloWorld
            }
        });
    </script>
</body>

</html>